# Maintainer: David Runge <dave@sleepmap.de>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Marcel Wysocki <maci@satgnu.net>
# Contributor: coolkehon <coolkehon at g m a i l>

pkgname=libircclient
pkgver=1.10
pkgrel=5
pkgdesc='Small but powerful library, which implements client-server IRC protocol'
arch=('loong64' 'x86_64')
url='https://www.ulduzsoft.com/linux/libircclient/'
license=('GPL2')
depends=('openssl')
makedepends=('python-sphinx')
provides=('libircclient.so')
source=("https://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('d677ceae0bfabc112671b351fb94d048399a7ad025ff33a2ff1ae6313382fcc78b64d499f2c882eb8b894abdde949562395819e4059fd14640dfae6757b0c259')

prepare() {
  cd "${pkgname}-${pkgver}"
  # fix include dir path
  sed -i "s/@\/include/&\/${pkgname}/" src/Makefile.in
  autoreconf -vi
}

build() {
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr \
              --libdir=/usr/lib \
              --enable-shared \
              --enable-openssl \
              --enable-ipv6
  make -C src
  make -C doc man
}

package() {
  cd "${pkgname}-${pkgver}"
  make -C src DESTDIR="${pkgdir}" install

  # docs
  install -d "${pkgdir}/usr/share/doc/${pkgname}"
  # man
  install -vDm 644 "doc/_build/man/${pkgname}.1" \
    -t "${pkgdir}/usr/share/man/man1/"
  # examples
  install -vDm 644 examples/* -t "${pkgdir}/usr/share/${pkgname}/examples"
  # docs
  install -vDm 644 {Changelog,README,THANKS} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
